<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>应急信息快报</title>
    <link rel="stylesheet" href="${ctxPath}/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/module/admin.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格工具栏 -->
            <form class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">应急上报种类:</label>
                        <div class="layui-input-inline">
                            <select name="reportspecies"></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">地点:</label>
                        <div class="layui-input-inline">
                            <input name="place" class="layui-input" placeholder="请输入地点"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态:</label>
                        <div class="layui-input-inline">
                            <select name="state">
                                <option value="">--请选择状态--</option>
                                <option value="0">待请求调拨</option>
                                <option value="1">待人员调拨</option>
                                <option value="2">待物资调拨</option>
                                <option value="3">待确认审批</option>
                                <option value="4">审批通过</option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn" lay-filter="tableSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button type="reset" class="layui-btn layui-btn-primary icon-btn">
                            <i class="layui-icon">&#xe669;</i>重置
                        </button>
                    </div>
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBar">
    <a class="layui-btn  layui-btn-xs" perm-show="report:sp" lay-event="sp">审批确认</a>
    <a class="layui-btn  layui-btn-xs" perm-show="report:ry" lay-event="ry">确认人员调拨</a>
    <a class="layui-btn  layui-btn-xs" perm-show="report:place" lay-event="place">分配地区</a>
    <a class="layui-btn  layui-btn-xs" perm-show="report:wz" lay-event="wz">确认物资调拨</a>
    <a class="layui-btn  layui-btn-xs" perm-show="report:diaobory" lay-event="diaobo">请求调拨人员</a>
    <a class="layui-btn  layui-btn-xs" perm-show="report:diaobowz" lay-event="diaobowz">请求调拨物资</a>

    <a class="layui-btn layui-btn-primary layui-btn-xs" perm-show="report:edit" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" perm-show="report:delete" lay-event="delete">删除</a>
</script>

<!-- js部分 -->
<script src="${ctxPath}/assets/libs/layui/layui.js"></script>
<script src="${ctxPath}/assets/js/common.js"></script>
<script>
    layui.use(['layer', 'table', 'tableX', 'notice', 'xnUtil', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;
        var tableX = layui.tableX;
        var admin = layui.admin;
        var form = layui.form;
        var notice = layui.notice;
        var xnUtil = layui.xnUtil;
        var laydate = layui.laydate;

        // 渲染字典下拉
        xnUtil.rendDictDropDown(null, 'reportspecies', 'emergencyreporttypes', '请选择应急上报种类', null);


       var insTb;
        $.get(getProjectUrl() +"getLoginUser",function(res){
            console.log(res.data);
            if(res.data.name.includes("人员负责人")){
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: getProjectUrl() + 'report/page?state=1&ryplace='+res.data.nickName,
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                if (d.state==0){
                                    return "<font style='color: red'>待请求调拨</font>";
                                }else if (d.state==1){
                                    return "<font style='color: blue'>待人员调拨</font>";
                                }else if (d.state==2){
                                    return "<font style='color: blue'>待物资调拨</font>";
                                }else if (d.state==3){
                                    return "<font style='color: blue'>待确认审批</font>";
                                }else if (d.state==4){
                                    return "<font style='color: green'>审批通过</font>";
                                }

                                }},
                            {field: 'renyuan', width:136 ,title: '请求调拨人数', sort: true,style:'color:red'},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},

                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else if(res.data.name.includes("物资负责人")){
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: getProjectUrl() + 'report/page?state=2&ryplace='+res.data.nickName,
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'wuzi', width:136 ,title: '请求物资情况', sort: true,style:'color:red'},

                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},

                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else if(res.data.name.includes("防火")){
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: res.data.name=="防火负责人"?getProjectUrl() + 'report/page?state=0&reportspecies=fanghuo':getProjectUrl() + 'report/page?state=3&reportspecies=fanghuo',
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},
                            {field: 'casualty', width:111 ,title: '伤亡人数', sort: true},
                            {field: 'economicloss', width:195 ,title: '直接经济损失（估算）', sort: true},
                            {field: 'reason', width:195 ,title: '发生原因（初步判断）', sort: true},
                            {field: 'measure', title: '先期处置措施', sort: true},
                            {field: 'nextmeasure', title: '下一步处置措施', sort: true},
                            {field: 'controlaccident', title: '事故控制情况', sort: true},
                            {field: 'forecastfuture', title: '未来走势预测', sort: true},
                            {field: 'sendunit', title: '报送单位', sort: true},
                            {field: 'signer', title: '签发人', sort: true},
                            {field: 'contact', title: '联系人', sort: true},
                            {field: 'phone', title: '联系电话', sort: true},
                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else if(res.data.name.includes("防汛")){
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: res.data.name=="防汛负责人"?getProjectUrl() + 'report/page?state=0&reportspecies=fangxun':getProjectUrl() + 'report/page?state=3&reportspecies=fangxun',
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},
                            {field: 'casualty', width:111 ,title: '伤亡人数', sort: true},
                            {field: 'economicloss', width:195 ,title: '直接经济损失（估算）', sort: true},
                            {field: 'reason', width:195 ,title: '发生原因（初步判断）', sort: true},
                            {field: 'measure', title: '先期处置措施', sort: true},
                            {field: 'nextmeasure', title: '下一步处置措施', sort: true},
                            {field: 'controlaccident', title: '事故控制情况', sort: true},
                            {field: 'forecastfuture', title: '未来走势预测', sort: true},
                            {field: 'sendunit', title: '报送单位', sort: true},
                            {field: 'signer', title: '签发人', sort: true},
                            {field: 'contact', title: '联系人', sort: true},
                            {field: 'phone', title: '联系电话', sort: true},
                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else if(res.data.name.includes("公共安全事件")){
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: res.data.name=="公共安全事件负责人"?getProjectUrl() + 'report/page?state=0&reportspecies=public':getProjectUrl() + 'report/page?state=3&reportspecies=public',
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},
                            {field: 'casualty', width:111 ,title: '伤亡人数', sort: true},
                            {field: 'economicloss', width:195 ,title: '直接经济损失（估算）', sort: true},
                            {field: 'reason', width:195 ,title: '发生原因（初步判断）', sort: true},
                            {field: 'measure', title: '先期处置措施', sort: true},
                            {field: 'nextmeasure', title: '下一步处置措施', sort: true},
                            {field: 'controlaccident', title: '事故控制情况', sort: true},
                            {field: 'forecastfuture', title: '未来走势预测', sort: true},
                            {field: 'sendunit', title: '报送单位', sort: true},
                            {field: 'signer', title: '签发人', sort: true},
                            {field: 'contact', title: '联系人', sort: true},
                            {field: 'phone', title: '联系电话', sort: true},
                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else if(res.data.name.includes("应急信息中心")||res.data.name.includes("区负责人")){
                insTb = tableX.render({
                    elem: '#dataTable',
                    url: getProjectUrl() + 'report/page?state=0',
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},
                            {field: 'casualty', width:111 ,title: '伤亡人数', sort: true},
                            {field: 'economicloss', width:195 ,title: '直接经济损失（估算）', sort: true},
                            {field: 'reason', width:195 ,title: '发生原因（初步判断）', sort: true},
                            {field: 'measure', title: '先期处置措施', sort: true},
                            {field: 'nextmeasure', title: '下一步处置措施', sort: true},
                            {field: 'controlaccident', title: '事故控制情况', sort: true},
                            {field: 'forecastfuture', title: '未来走势预测', sort: true},
                            {field: 'sendunit', title: '报送单位', sort: true},
                            {field: 'signer', title: '签发人', sort: true},
                            {field: 'contact', title: '联系人', sort: true},
                            {field: 'phone', title: '联系电话', sort: true},
                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }else{
                 insTb = tableX.render({
                    elem: '#dataTable',
                    url: getProjectUrl() + 'report/page?signer='+res.data.name,
                    page: true,
                    toolbar: ['<p>',
                        '<button lay-event="add" perm-show="report:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                        '<button lay-event="delete" perm-show="report:delete" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                        '</p>'].join(''),
                    cellMinWidth: 100,
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'reportspecies', width:136 ,title: '应急上报种类', sort: true, templet: function (d) {  return xnUtil.rendDataTableDict(d.reportspecies, 'emergencyreporttypes'); }},
                            {field: 'state', width:109 ,title: '状态', sort: true,templet: function (d) {
                                    if (d.state==0){
                                        return "<font style='color: red'>待请求调拨</font>";
                                    }else if (d.state==1){
                                        return "<font style='color: blue'>待人员调拨</font>";
                                    }else if (d.state==2){
                                        return "<font style='color: blue'>待物资调拨</font>";
                                    }else if (d.state==3){
                                        return "<font style='color: blue'>待确认审批</font>";
                                    }else if (d.state==4){
                                        return "<font style='color: green'>审批通过</font>";
                                    }

                                }},
                            {field: 'occurrence', width:109 ,title: '发生情况', sort: true},
                            {field: 'eventtime',width:115 , title: '事件时间', sort: true},
                            {field: 'place', title: '地点', sort: true},
                            {field: 'unit', title: '单位', sort: true},
                            {field: 'afterbriefly', width:111 ,title: '简要经过', sort: true},
                          /*  {field: 'casualty', width:111 ,title: '伤亡人数', sort: true},
                            {field: 'economicloss', width:195 ,title: '直接经济损失（估算）', sort: true},*/
                            {field: 'reason', width:195 ,title: '发生原因（初步判断）', sort: true},
                            {field: 'measure', title: '先期处置措施', sort: true},
                            {field: 'nextmeasure', title: '下一步处置措施', sort: true},
                            {field: 'controlaccident', title: '事故控制情况', sort: true},
                            {field: 'forecastfuture', title: '未来走势预测', sort: true},
                            {field: 'sendunit', title: '报送单位', sort: true},
                            {field: 'signer', title: '签发人', sort: true},
                            {field: 'contact', title: '联系人', sort: true},
                            {field: 'phone', title: '联系电话', sort: true},
                            {title: '操作', toolbar: '#tableBar', align: 'center', width: 250, minWidth: 250}
                        ]
                    ],
                    done: function(res, curr, count) {
                        xnUtil.tableDone(insTb, res, curr, count);
                    }
                });
            }
        })


        /* 表格搜索 */
        form.on('submit(tableSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });

        /* 表格工具条点击事件 */
        table.on('tool(dataTable)', function (obj) {
            /* 删除 */
            if (obj.event === 'delete') {
                layer.confirm('确定要操作该数据吗？', {
                    skin: 'layui-layer-admin',
                    shade: .1
                }, function () {
                    admin.req(getProjectUrl() + 'report/delete', JSON.stringify([{'id': obj.data.id}]), function(res){
                        layer.msg(res.message, {icon: 1, time: 1000}, function () {
                            insTb.reload();
                        });
                    }, 'post');
                });
            }
            /* 编辑 */
            if (obj.event === 'edit') {
                showAddOrUpdateModel(obj.data);
            }
            /*调拨人员*/
            if (obj.event === 'diaobo') {
                diaobo(obj.data);
            }
            /*调拨物资*/
            if (obj.event === 'diaobowz') {
                diaobowz(obj.data);
            }
            if (obj.event === 'place') {
                place(obj.data);
            }
            if (obj.event === 'ry') {
                layer.confirm('确定要按需分配人员吗？', {
                    skin: 'layui-layer-admin',
                    shade: .1
                }, function () {
                    admin.req(getProjectUrl() + 'report/ry', JSON.stringify([{'id': obj.data.id}]), function(res){
                        layer.msg(res.message, {icon: 1, time: 1000}, function () {
                            insTb.reload();
                        });
                    }, 'post');
                });
            }

            if (obj.event === 'wz') {
                layer.confirm('确定要按需分配物资吗？', {
                    skin: 'layui-layer-admin',
                    shade: .1
                }, function () {
                    admin.req(getProjectUrl() + 'report/wz', JSON.stringify([{'id': obj.data.id}]), function(res){
                        layer.msg(res.message, {icon: 1, time: 1000}, function () {
                            insTb.reload();
                        });
                    }, 'post');
                });
            }

            if (obj.event === 'sp') {
                layer.confirm('确定审批通过吗？', {
                    skin: 'layui-layer-admin',
                    shade: .1
                }, function () {
                    admin.req(getProjectUrl() + 'report/sp', JSON.stringify([{'id': obj.data.id}]), function(res){
                        layer.msg(res.message, {icon: 1, time: 1000}, function () {
                            insTb.reload();
                        });
                    }, 'post');
                });
            }
        });

        /* 表格头工具栏点击事件 */
        table.on('toolbar(dataTable)', function (obj) {
            if (obj.event === 'add') { // 添加
                showAddOrUpdateModel();
            }
            if (obj.event === 'delete') { // 删除
                var checkRows = table.checkStatus('dataTable');
                if (checkRows.data.length === 0) {
                    notice.msg('请选择要操作的数据', {icon: 2});
                    return;
                }
                layer.confirm('确定要操作该数据吗？', {
                    skin: 'layui-layer-admin',
                    shade: .1
                }, function () {
                    var ids = checkRows.data.map(function (d) {
                        return {"id": d.id};
                    });
                    admin.req(getProjectUrl() + 'report/delete', JSON.stringify(ids), function(res){
                        layer.msg(res.message, {icon: 1, time: 1000}, function () {
                            insTb.reload();
                        });
                    }, 'post');
                });
            }
        });

        // 显示表单弹窗
        function showAddOrUpdateModel(data) {
            var layIndex = admin.open({
                title: (data ? '修改' : '添加') + '应急信息快报',
                url: getProjectUrl() + 'report/form',
                area: ['800px',''],
                data: { data: data },     // 传递数据到表单页面
                end: function () {
                    var layerData = admin.getLayerData(layIndex, 'formOk');
                    if (layerData) {  // 判断表单操作成功标识
                        insTb.reload();  // 成功刷新表格
                    }
                },
                success: function (layero, dIndex) {
                    // 弹窗超出范围不出现滚动条
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    $(layero).find('[lay-submit]').focus();
                }
            });
        }
        function  place(data){
            var layIndex = admin.open({
                title: '分配地区',
                url: getProjectUrl() + 'report/place',

                area: ['800px','500px'],
                data: { data: data },     // 传递数据到表单页面
                end: function () {
                    var layerData = admin.getLayerData(layIndex, 'formOk');
                    if (layerData) {  // 判断表单操作成功标识
                        insTb.reload();  // 成功刷新表格
                    }
                },
                success: function (layero, dIndex) {
                    // 弹窗超出范围不出现滚动条
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    $(layero).find('[lay-submit]').focus();
                }
            });
        }
        function diaobo(data) {
            var layIndex = admin.open({
                title: '调拨人员',
                url: getProjectUrl() + 'report/diaobo',
                area: ['800px',''],
                data: { data: data },     // 传递数据到表单页面
                end: function () {
                    var layerData = admin.getLayerData(layIndex, 'formOk');
                    if (layerData) {  // 判断表单操作成功标识
                        insTb.reload();  // 成功刷新表格
                    }
                },
                success: function (layero, dIndex) {
                    // 弹窗超出范围不出现滚动条
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    $(layero).find('[lay-submit]').focus();
                }
            });
        }
        function diaobowz(data){
            var layIndex = admin.open({
                title: '调拨物资',
                url: getProjectUrl() + 'report/diaobowz',
                area: ['800px',''],
                data: { data: data },     // 传递数据到表单页面
                end: function () {
                    var layerData = admin.getLayerData(layIndex, 'formOk');
                    if (layerData) {  // 判断表单操作成功标识
                        insTb.reload();  // 成功刷新表格
                    }
                },
                success: function (layero, dIndex) {
                    // 弹窗超出范围不出现滚动条
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    $(layero).find('[lay-submit]').focus();
                }
            });
        }
    });
</script>
</body>
</html>
